package com.zmytest.annotation;

import com.zmytest.annotation.bean.BeanTest;
import com.zmytest.annotation.scope.prototype.ScopePrototype;
import com.zmytest.annotation.scope.request.ScopeRequest;
import com.zmytest.annotation.scope.session.ScopeSession;
import com.zmytest.annotation.scope.session.ScopeSessionImpl;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.web.context.WebApplicationContext;

/**
 * Created on 2018/12/29.
 *
 * @author zhangmingyu
 */
@Configuration
public class BeanConfig {

    @Bean
    public BeanTest getBeanTest(){
        return new BeanTest();
    }

    @Bean
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public ScopePrototype getScopePrototype(){
        return new ScopePrototype();
    }

    @Bean
    @Scope(value = WebApplicationContext.SCOPE_REQUEST,proxyMode = ScopedProxyMode.TARGET_CLASS)
    public ScopeRequest getScopeRequest(){
        return new ScopeRequest();
    }


    @Bean
    @Scope(value = WebApplicationContext.SCOPE_SESSION,proxyMode = ScopedProxyMode.INTERFACES)
    public ScopeSession getScopeSession(){
        return new ScopeSessionImpl();
    }
}
